<?php

# login expects a form post with the following fields:
# username, password, remember(checkbox)


require_once($_SERVER['DOCUMENT_ROOT'].'/includes/site_defaults.php');

if (!isset($_SESSION)) {
	session_start();
}

if (isset($_POST['email']) && isset($_POST['password'])) {

	$remember = $_POST['remember'] == "true" ? true : false;
	$id = LoginUser("", $_POST['email'], sha1($_POST['password']));

	if ($id > 0 && $remember) {
		setcookie("id", $id, mktime()+60*60*24*365,"/");
	}
	
	if ($id > 0) {
		echo "Login Succeeded.";
	} else {
		echo "Login Failed.";
	}

}

?>
